import java.util.List;
import java.util.Set;

import net.mfjassociates.finance.domain.mfjfin.ExpenseDetails;
import net.mfjassociates.finance.domain.mfjfin.ExpenseReports;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.transaction.annotation.Transactional;


public class TestJpa {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("META-INF/spring/applicationContext.xml");
		TestJpa tjpa=new TestJpa();
		tjpa.process();
	}
	@Transactional
	public void process() {
		List<ExpenseReports> rep=ExpenseReports.findAllExpenseReportses();
		for (ExpenseReports er : rep) {
			System.out.println("no="+er.getExpenseReportId()+", name='"+er.getExpenseRptName()+"'");
			processER(er);
		}
	}
	
	public void processER(ExpenseReports er) {
		Set<ExpenseDetails> items= er.getExpenseDetailss();
		for (ExpenseDetails ed : items) {
			System.out.println(ed.getExpenseDate()+"', amount="+ed.getExpenseItemAmount()+", desc='"+ed.getExpenseItemDescription());
		}
	}

}
